package cn.smxy.ln.controller;

import cn.smxy.ln.common.lang.Result;
import cn.smxy.ln.pojo.Work;
import cn.smxy.ln.service.WorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ln
 * @date 2022年05月24日 19:54
 */
@RestController
@RequestMapping("/work/consumer")
public class WorkController {

    @Autowired
    WorkService workService;

    @GetMapping("/list")
    public Result queryByProjectId(@RequestParam(value = "content", required = false) String content, @RequestParam(value = "scoreRule", required = false) String scoreRule, @RequestParam(value = "projectId", required = false) Long projectId) {
        return Result.succ(workService.queryByProjectId(content, scoreRule, projectId));
    }

    @PostMapping("/save")
    public Result save(@RequestBody Work work) {
        return Result.succ(workService.save(work));
    }

    @PostMapping("/delete")
    public Result delete(@RequestParam(value = "id") Long id) {
        return Result.succ(workService.delete(id));
    }

    @PostMapping("/update")
    public Result update(@RequestBody Work work) {
        return Result.succ(workService.update(work));
    }

}
